import java.util.Arrays;
import java.util.LinkedList;
import java.util.List;
import java.util.ListIterator;

public class E12_ListIterators {

	static void reverse(List<Integer> list) {
		ListIterator<Integer> fwd = list.listIterator();
		ListIterator<Integer> rev = list.listIterator(list.size());

		int min = list.size() >> 1;
		for (int i = 0; i < min; i++) {
			Integer temp = fwd.next();
			fwd.set(rev.previous());
			rev.set(temp);
		}
	}

	public static void main(String[] args) {
		List<Integer> src = Arrays.asList(1, 2, 3, 4, 5, 6, 7, 8, 9, 10);
		List<Integer> dest = new LinkedList<Integer>(src);
		System.out.println(src);
		System.out.println(dest);

		reverse(dest);

		System.out.println(src);
		System.out.println(dest);
	}

}
